﻿//编辑用户表
EditSys_UserPwd = function() {
    var EditSys_UserForm = Ext.create("Ext.form.Panel", {
        width: 360,
        height: 260,
        plain: true,
        layout: "anchor",
        defaultType: "textfield",
        labelWidth: 55,
        baseCls: "x-plain",
        defaults: { labelAlign: 'right', anchor: "90%", msgTarget: "side" },
        buttonAlign: "center",
        defaultType: 'textfield',
        bodyStyle: "padding:0 0 0 0",
        items: [
                    {
                        name: "U_Password",
                        fieldLabel: "<font color='red'>*</font>旧密码",
                        allowBlank: false,
                        inputType: 'password',

                        blankText: "密码md5加密字符不能为空",
                        regex: /^[\da-zA-Z]{1,20}$/,
                        regexText: "请填写1～9个数字或字母"
                    }, {
                        name: "U_PasswordNew",
                        fieldLabel: "<font color='red'>*</font>新密码",
                        allowBlank: false,
                        inputType: 'password',
                        blankText: "密码md5加密字符不能为空",
                        regex: /^[\da-zA-Z]{1,20}$/,
                        regexText: "请填写1～9个数字或字母"
                    }, {
                        name: "U_PasswordNew2",
                        fieldLabel: "<font color='red'>*</font>确认新密码",
                        allowBlank: false,
                        inputType: 'password',
                        blankText: "密码md5加密字符不能为空"

                    }
        ]
    });

    var EditSys_UserWin = new Ext.Window({
        title: "修改用户密码",
        width: 400,
        height: 260,
        bodyStyle: "padding:10px 0 0 15px",
        items: [EditSys_UserForm],
        buttons: [{
            text: "修改",
            minWidth: 70,
            handler: function() {
            if (EditSys_UserForm.getForm().findField("U_PasswordNew").getValue() == EditSys_UserForm.getForm().findField("U_PasswordNew2").getValue()) {
                    if (EditSys_UserForm.getForm().isValid()) {
                        //弹出效果 Ext.MessageBox.alert("asdf");
                        Ext.MessageBox.show
                                (
                                    {
                                        msg: '正在保存，请稍等...',
                                        progressText: 'Saving...',
                                        width: 300,
                                        wait: true,
                                        waitConfig: { interval: 200 },
                                        icon: 'download',
                                        animEl: 'saving'
                                    }
                                );
                        setTimeout(function() { }, 1000);
                        EditSys_UserForm.form.submit({
                            url: "/Manager/Sys_User/UpdatePwd/",
                            method: "POST",
                            success: function(form, action) {
                                //成功后
                                Ext.MessageBox.hide();
                                var flag = action.result.success;
                                if (flag == "true") {
                                   Ext.helper.msg("恭喜", "修改成功!");
                                    EditSys_UserWin.hide();
                                }
                                else {
                                    var message = action.result.message;
                                    if (message) {
                                        Ext.MessageBox.alert("修改失败!", message);
                                    }
                                    else {
                                        Ext.MessageBox.alert("提示!", "修改失败!");
                                        EditSys_UserWin.hide();
                                    }

                                }
                            },
                            failure: function(form, action) {
                                Ext.MessageBox.alert("提示!", "修改失败!");
                                EditSys_UserWin.hide();
                            }
                        });
                    }

                }
                else
                    Ext.MessageBox.alert("提示!", '两次密码输入不一致');
            }
        }, {
            text: "取 消",
            minWidth: 70,
            handler: function() {
                EditSys_UserWin.hide();
            }

}]

        });

        EditSys_UserWin.show();

    }
  
